package oxing.core;

public abstract class Application implements Runnable {
	private Thread thread;
	private Scene scene;

	public final void run() {
		try {
			main();
		} catch (InterruptedException e) {
		}
	}

	protected abstract void main() throws InterruptedException;

	protected final void setCurrentScene(Scene s) {
		scene = s;
	}

	protected final Scene getCurrentScene() {
		return scene;
	}

	public final void onResume() {
		thread = new Thread(this);
		thread.start();
	}

	public final void onPause() {
		thread.interrupt();
		while (true) {
			try {
				thread.join();
				break;
			} catch (Exception e) {
			}
		}
	}
}
